From: Julien Grall Date: Wed, 13 Nov 2013 13:37:50 +0000 (+0000) Subject: xen: Check if the range is valid in init_domheap_pages X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~5903 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=45ffa79447954e68892322d985e72620d32ac16d;p=xen.git xen: Check if the range is valid in init_domheap_pages On ARM, when an initrd is given to xen by U-boot, it will reserve the memory in the device tree. In this case, when xen decides to free unused memory, dt_unreserved_regions will call init_domheap_pages with the start and the end of range equals. But the latter assumes that (start > end), if not Xen will hang because the number of pages is equals to (unsigned)-1. Signed-off-by: Julien Grall Acked-by: Keir Fraser Acked-by: Ian Campbell CC: Jan Beulich --- diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 4c17fbde40..0701333fe1 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1429,6 +1429,9 @@ void init_domheap_pages(paddr_t ps, paddr_t pe) smfn = round_pgup(ps) >> PAGE_SHIFT; emfn = round_pgdown(pe) >> PAGE_SHIFT; + if ( emfn <= smfn ) + return; + init_heap_pages(mfn_to_page(smfn), emfn - smfn); }